package com.corpgovernment.supplier.mapper;


import com.corpgovernment.organization.common.mybatis.TkMapper;
import com.corpgovernment.supplier.dto.MbSupplierProductDto;
import com.corpgovernment.supplier.entity.db.MbSupplierProduct;
import com.corpgovernment.supplier.vo.MbSupplierProductVo;
import com.ctrip.corp.obt.generic.utils.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;

@Repository
@Mapper
public interface MbSupplierProductMapper extends TkMapper<MbSupplierProduct> {
    
    List<MbSupplierProductVo> pageQuery(@Param("nameOrCode") String nameOrCode,@Param("productType") String productType, @Param("supplierCode") String supplierCode);

    MbSupplierProductDto selectBySupplierCodeAndProductTypeAndOperateType(@Param("supplierCode") String supplierCode, @Param("productType") String productType, @Param("operateType") String operateType);

    List<MbSupplierProductDto> selectByProductTypeAndOperateTypeInSupplierCode(@Param("productType") String productType, @Param("operateType") String operateType, @Param("supplierCodeList") List<String> supplierCodeList);

    default List<MbSupplierProduct> list(String productType) {
        if (StringUtils.isEmpty(productType)) {
            return new ArrayList<>(0);
        }
        Example example = new Example(MbSupplierProduct.class);
        example.createCriteria().andEqualTo("productType", productType);
        return this.selectByExample(example);
    }

}
